/**
 * 动态规划解题
 */
public class main {

    public static void main(String[] args) {
        System.out.println(divisorGame(1022));
    }

    public static boolean divisorGame(int N) {
        int[] remain = new int[N + 1];
        for (int i = 0; i < N + 1; i++) {
            remain[i] = 1;
        }
        for (int j = 2; j <= N; j++) {
            for (int i = 1; i < j; i++) {
                if (j % i == 0) {
                    if (remain[j - i] == 1) {
                        remain[j] = 0;
                        break;
                    }
                }
            }
        }
        return !(remain[N] == 1);
    }
}
